﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace ddb_BT1
{
    public partial class frmDangNhap : DevExpress.XtraEditors.XtraForm
    {
        public frmDangNhap(frmMain f ): this()
        {
            frm = f;
        }
        public frmDangNhap()
        {
            InitializeComponent();
        }
        frmMain frm;
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            DataTable dt = DataProvider.getDataTable(string.Format("select * from NGUOIDUNG where username='{0}' and pass='{1}'",txtUsername.Text,txtPassword.Text));
            if (dt.Rows.Count > 0)
            {
                this.Hide();
                frm.username = txtUsername.Text.Trim().ToUpper();
                frm.PhanQuyen();
            }

        }

        private void frmDangNhap_Load(object sender, EventArgs e)
        {

        }

        private void frmDangNhap_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }
    }
}